export default{
    getDate(val){
        if (!val) {
            return ''
        }
        let now = new Date(val),
            y = now.getFullYear(),
            m = now.getMonth() + 1,
            d = now.getDate();
        return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);
    },
    getTimes(val){
        if (!val) {
            return ''
        }
        var now = new Date(val),
        y = now.getFullYear(),
        m = now.getMonth() + 1,
        d = now.getDate();
        return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substr(0, 8);
    },
    getQueryVariable(variable){
       var query = window.location.href.split('?')[1];
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
    },
    zeroNum(num){
        let exp = /[0-9]/g;
        if(exp.test(num)){
            return num;
        } else {
            return ''
        }
    },
    money(money){
        let exp = /^([1-9][\d]{0,7}|0)(\.[\d]{0,9})?$/g;
        if(exp.test(money)){
            return money;
        } else {
            return ''
        }
    },
}